<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta content="telephone=no" name="format-detection"/>
    <meta content="email=no" name="format-detection"/>
    <title>用户充值</title>
    <link rel="stylesheet" href="__PUBLIC__/css/refills.css">
    <script type="text/javascript" src="__PUBLIC__/js/jquery-1.7.1.min.js"></script>
    <script src="__PUBLIC__/js/layer/layer.js"></script>
</head>
<body>
<style>
	.m-margin{
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
}
.btn-submit{
    border: none;
    line-height: 12vw;
    background-color: darkorange;
    color: #fff;
    border-radius: 5px;
    margin: 4vw;
    text-align: center;
}
</style>
<div class="g-content">
    <ul class="list">
        <li class="list-li ">
            <div class="left icon-1">5G</div>
            <label class="m-label">
                <input class="m-radio" type="radio" value="5" name="money">
                <div class="right">¥5</div>
            </label>
        </li>
        <li class="list-li ">
            <div class="left icon-1">10G</div>
            <label class="m-label">
                <input class="m-radio" type="radio" value="10" name="money">
                <div class="right">¥10</div>
            </label>
        </li>
        <li class="list-li ">
            <div class="left icon-1">15G</div>
            <label class="m-label">
                <input class="m-radio" type="radio" value="15" name="money">
                <div class="right">¥15</div>
            </label>
        </li>
        <li class="list-li ">
            <div class="left icon-1">30G</div>
            <label class="m-label">
                <input class="m-radio" type="radio" value="30" name="money">
                <div class="right">¥30</div>
            </label>
        </li>
        <li class="list-li">
            <div class="left icon-2">50G</div>
            <label class="m-label">
                <input class="m-radio" type="radio" value="50" name="money">
                <div class="right">¥50</div>
            </label>
        </li>
        <li class="list-li">
            <div class="left icon-2">100G</div>
            <label class="m-label">
                <input class="m-radio" type="radio" value="100" name="money">
                <div class="right">¥100</div>
            </label>
        </li>
    </ul>
    <div class="m-margin">
        <a href='javascript:void(0);' style="color:white;text-decoration:none" onclick='pay()'><div class="btn-submit">确定充值</div></a>
    </div>
    <!-- <a href='javascript:void(0);' class='btn btn-success' onclick='pay()'>充值</a> -->
</div>
</body>
<script id='spay-script' src='https://jspay.beecloud.cn/1/pay/jsbutton/returnscripts?appId=cd264072-eb48-4a9b-beb7-31d96d8f203f'></script>
<script>
    function pay(){
        var money=$("input[type=radio]:checked").val();
        if($("input[type=radio]:checked").is(':checked')==false){
            layer.msg('请选择充值金额');
            return false;
        }
        $.post('__MODULE__/Recharge/to_pay',{money:money},function(data){
            if(data.code=='1001'){
                // console.log(data);
                var data=data.result;
                asyncPay(data.title,data.money,data.orderno,data.sign);
            }else{
                layer.msg(data.result,{time:1000});
            }
        });
    }
    function bcPay(title,amount,sn,sign) {
        var to_url='http://kkddapi.86tudi.com/Recharge/pay';
        // var amount=parseInt(amount);
        BC.click({
            "title":title,
            "amount":amount,
            "out_trade_no":sn, //唯一订单号
            "sign" :sign,
            'return_url':to_url
        });
    }

    function asyncPay(title,amount,sn,sign) {
        if (typeof BC == "undefined") {
            if (document.addEventListener) { // 大部分浏览器
                document.addEventListener('beecloud:onready', bcPay, false);
            } else if (document.attachEvent) { // 兼容IE 11之前的版本
                document.attachEvent('beecloud:onready', bcPay);
            }
        } else {
            bcPay(title,amount,sn,sign);
        }
    }
</script>
</html>